package com.gxp.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;


public class CommonInterceptor implements HandlerInterceptor {
	Logger logger = Logger.getLogger(CommonInterceptor.class);

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception arg3)
			throws Exception {
		logger.debug("after completion"); 
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler, ModelAndView mv) throws Exception {
		logger.debug("post-handle"); 
	}

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
			Object handler) throws Exception {
		logger.debug("Pre-handle"); 
		WebUtils.setSessionAttribute(request, "CURRENT_RESTFUL_URL", request.getRequestURL());
		return true;
	}

}
